package weekend01;

import java.util.Locale;

public class StringDemo {
    public static void main(String[] args) {
        String str = "百度一下，你就知道";
        System.out.println("字符串的长度为:"+str.length());

        String str1 = "   百度一下，你就知道       ";
        System.out.println(str1);
        System.out.println(str1.trim());

        String str2 = "Bai Du";
        System.out.println(str2.toUpperCase());
        System.out.println(str2.toLowerCase());

        System.out.println("字符串str2是否以'B'开头:"+ str2.startsWith("B"));
        System.out.println("字符串str2是否以'u'结尾:"+ str2.endsWith("u"));

        System.out.println(str2.charAt(4));

        String str3 = "Google";
        System.out.println("字符'o'第一次出现的位置是:"+str3.indexOf("o"));
        System.out.println("字符'o'最后一次出现的位置是:"+str3.lastIndexOf("o"));

        String str4 = "www.baidu.com";
        int start = str4.indexOf(".")+1;
        int end = str4.indexOf(".",start);
        System.out.println(str4.substring(start,end));

        int a  = 123456789;
        String str5 = String.valueOf(a);
        System.out.println(a);

        String str6 = "好好学习JAVA";
        StringBuilder builder = new StringBuilder(str6);
        builder.append(",为了找个好工作");
        System.out.println(builder);
        builder.replace(9,16,"为了拯救世界");
        System.out.println(builder);
        builder.delete(0,9);
        System.out.println(builder);
        builder.insert(0,"活着,");
        System.out.println(builder);

    }
}
